package com.itheima;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

public class PropertiesTest {
    public static void main(String[] args) throws IOException {
        Properties properties = new Properties();

        FileReader fr = new FileReader("/Users/oscar/Desktop/HQWork/学习资料/code/MyOtherStream/game.txt");
        properties.load(fr);
        fr.close();

        String count = properties.getProperty("count");
        int i = Integer.parseInt(count);

        if (i >= 3) {
            System.out.println("游戏试玩已结束，继续玩请充值。");
        } else {
            GuessNumber.start();

            i++;
            properties.setProperty("count", String.valueOf(i));

            FileWriter fw = new FileWriter("/Users/oscar/Desktop/HQWork/学习资料/code/MyOtherStream/game.txt");
            properties.store(fw, null);
            fw.close();
        }
    }
}
